package cn.wolfcode.service;

import cn.wolfcode.domain.OperateIntergralVo;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

/**
 * Created by lanxw
 */
@LocalTCC
public interface IUsableIntegralService {
    /**
     * 积分扣减
     * @param operateIntergralVo
     * @return
     */
    @TwoPhaseBusinessAction(name = "decrIntegralTry",
            commitMethod = "decrIntegralCommit",
            rollbackMethod = "decrIntegralRollback")
    void decrIntegralTry(@BusinessActionContextParameter(paramName = "operateIntergralVo")
                                 OperateIntergralVo operateIntergralVo,
                      BusinessActionContext context);

    void decrIntegralCommit(BusinessActionContext context);
    void decrIntegralRollback(BusinessActionContext context);
    /**
     * 积分退款
     * @param vo
     * @return
     */
    int addIntegral(OperateIntergralVo vo);
}
